﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 事件
{
    public delegate void MyDelegate();    //定义委托类型
    class Program
    {
        class Text
        {
            public event MyDelegate MakeGreeting;   //定义事件，事件可以看作一个特殊的委托对象
            public void Greeting()
            {
                MakeGreeting();
            }
        }
        public static void ChineseGreeting()
        {
            Console.WriteLine("早上好");
        }
        public static void EnglishGreeting()
        {
            Console.WriteLine("good morning");
        }
        static void Main(string[] args)
        {
            Text t = new Text();
            t.MakeGreeting += ChineseGreeting;
            t.MakeGreeting += EnglishGreeting;
            t.Greeting();

        }
    }
}
